package com.neusoft.healthcity.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neusoft.healthcity.entity.ViewDeathInfo;
import com.neusoft.healthcity.entity.ViewInfectiousDiseases;
import com.neusoft.healthcity.mapper.ViewDeathInfoMapper;
import com.neusoft.healthcity.service.ViewDeathInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author songjihong
 * @since 2021-04-06
 */
@Service
@Primary
public class ViewDeathInfoServiceImpl extends ServiceImpl<ViewDeathInfoMapper, ViewDeathInfo> implements ViewDeathInfoService {
    /**
     * 获取指定时间段的死亡视图中的数据
     * @param startTime
     * @param endTime
     * @return
     */
    @Override
    public List<ViewDeathInfo> getScheduledDeathInfo(String startTime, String endTime) {
        QueryWrapper<ViewDeathInfo> queryWrapper = new QueryWrapper<>();

        if(endTime != null) {
            queryWrapper.and(i -> i.ge("OperateDate", startTime).lt("OperateDate", endTime));
        }else{
            queryWrapper.eq("OperateDate",startTime);
        }

        List<ViewDeathInfo> deathInfoList = baseMapper.selectList(queryWrapper);
        return deathInfoList;
    }
}
